{%TEMPLATE->struct/head%}
{%TEMPLATE->struct/menu%}
<h2>Permission Group '[[htmlentities([[group.getGroupName()]], ENT_QUOTES, "UTF-8")]]'</h2>
{%TEMPLATE->struct/messages%}
<h3>Current Members</h3>
<div class="card">
  <div class="table-responsive">
    <table class="table table-bordered">
		  <tr>
			  <th>User ID</th>
			  <th>Username</th>
		  </tr>
		  {{FOREACH user;[[users]]}}
			  <tr>
				  <td>[[user.getId()]]</td>
				  <td><a href="users.php?id=[[user.getId()]]">[[htmlentities([[user.getUsername()]], ENT_QUOTES, 'UTF-8')]]</a></td>
			  </tr>
		  {{ENDFOREACH}}
		  {{IF [[sizeof([[users]])]] == 0}}
			  <tr><td>---</td><td>---</td></tr>
		  {{ENDIF}}
	  </table>
  </div>
</div>
<h3>Permissions</h3>
<form action="access.php?id=[[group.getId()]]" method="post">
	<input type="hidden" name="csrf" value="[[csrf]]">
	<input type="hidden" name="groupId" value="[[group.getId()]]">
	<input type='hidden' name='action' value='[[$DAccessControlAction::EDIT]]'>
	<div class="card">
    <div class="table-responsive">
      <table class="table table-bordered">
			  <tr>
				  <th>Permission</th>
				  <th>Setting</th>
			  </tr>
			  {{FOREACH constant;[[constants]]}}
				  <tr>
					  <td>[[DAccessControl::getDescription([[constant]])]]</td>
					  <td>
						  {{IF [[perm]] == 'ALL'}}
							  <select name="perm[]" class="form-control" title="Permission">
								  <option selected>Allowed (enforced)</option>
							  </select>
						  {{ELSE}}
							  <select name="perm[]" class="form-control" title="Permission">
								  <option value="[[constant]]-0" {{IF [[perm.getVal([[constant]])]] == false}}selected{{ENDIF}}>No Permission{{IF [[perm.getVal([[constant]])]] == false}} (current){{ENDIF}}</option>
								  <option value="[[constant]]-1" {{IF [[perm.getVal([[constant]])]] == true}}selected{{ENDIF}}>Allowed{{IF [[perm.getVal([[constant]])]] == true}} (current){{ENDIF}}</option>
							  </select>
						  {{ENDIF}}
					  </td>
				  </tr>
			  {{ENDFOREACH}}
			  {{IF [[perm]] != 'ALL'}}
				  <tr>
					  <td colspan="2" class="text-center">
						  <button type="submit" class="btn btn-success">Save Permissions</button>
					  </td>
				  </tr>
			  {{ENDIF}}
		  </table>
    </div>
	</div>
</form>
{%TEMPLATE->struct/foot%}
